{{ header }}
<div id="affiliate-register" class="container">
  <ul class="breadcrumb">
    {% for breadcrumb in breadcrumbs %}
      <li class="breadcrumb-item"><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
    {% endfor %}
  </ul>
  {% if error_warning %}
    <div class="alert alert-danger alert-dismissible"><i class="fas fa-exclamation-circle"></i> {{ error_warning }}</div>
  {% endif %}
  <div class="row">{{ column_left }}
    <div id="content" class="col">{{ content_top }}
      <h1>{{ heading_title }}</h1>
      <p>{{ text_account_already }}</p>
      <p>{{ text_signup }}</p>
      <form action="{{ action }}" method="post" enctype="multipart/form-data">
        <fieldset id="account">
          <legend>{{ text_your_details }}</legend>
          <div class="form-group required" style="display: {% if customer_groups|length > 1 %} block {% else %} none {% endif %};">
            <label class="col-sm-2 col-form-label">{{ entry_customer_group }}</label>
            <div class="col-sm-10">{% for customer_group in customer_groups %}
                {% if customer_group.customer_group_id == customer_group_id %}
                  <div class="form-check">
                    <label><input type="radio" name="customer_group_id" value="{{ customer_group.customer_group_id }}" class="form-check-input" checked="checked"/>
                      {{ customer_group.name }}</label>
                  </div>
                {% else %}
                  <div class="form-check">
                    <label><input type="radio" name="customer_group_id" value="{{ customer_group.customer_group_id }}" class="form-check-input"/>
                      {{ customer_group.name }}</label>
                  </div>
                {% endif %}
              {% endfor %}</div>
          </div>
          <div class="form-group row required">
            <label class="col-sm-2 col-form-label" for="input-firstname">{{ entry_firstname }}</label>
            <div class="col-sm-10">
              <input type="text" name="firstname" value="{{ firstname }}" placeholder="{{ entry_firstname }}" id="input-firstname" class="form-control"/>
              {% if error_firstname %}
                <div class="text-danger">{{ error_firstname }}</div>
              {% endif %}
            </div>
          </div>
          <div class="form-group row required">
            <label class="col-sm-2 col-form-label" for="input-lastname">{{ entry_lastname }}</label>
            <div class="col-sm-10">
              <input type="text" name="lastname" value="{{ lastname }}" placeholder="{{ entry_lastname }}" id="input-lastname" class="form-control"/>
              {% if error_lastname %}
                <div class="text-danger">{{ error_lastname }}</div>
              {% endif %}
            </div>
          </div>
          <div class="form-group row required">
            <label class="col-sm-2 col-form-label" for="input-email">{{ entry_email }}</label>
            <div class="col-sm-10">
              <input type="text" name="email" value="{{ email }}" placeholder="{{ entry_email }}" id="input-email" class="form-control"/>
              {% if error_email %}
                <div class="text-danger">{{ error_email }}</div>
              {% endif %}
            </div>
          </div>
          <div class="form-group row required">
            <label class="col-sm-2 col-form-label" for="input-telephone">{{ entry_telephone }}</label>
            <div class="col-sm-10">
              <input type="text" name="telephone" value="{{ telephone }}" placeholder="{{ entry_telephone }}" id="input-telephone" class="form-control"/>
              {% if error_telephone %}
                <div class="text-danger">{{ error_telephone }}</div>
              {% endif %}
            </div>
          </div>
          {% for custom_field in custom_fields %}
            {% if custom_field.location == 'account' %}
              {% if custom_field.type == 'select' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <select name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">
                      <option value="">{{ text_select }}</option>
                      {% for custom_field_value in custom_field.custom_field_value %}
                        {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
                          <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option>
                        {% else %}
                          <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
                        {% endif %}
                      {% endfor %}
                    </select>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'radio' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <div>
                      {% for custom_field_value in custom_field.custom_field_value %}
                        <div class="form-check">
                          {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
                            <label><input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input" checked="checked"/>
                              {{ custom_field_value.name }}</label>
                          {% else %}
                            <label><input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/>
                              {{ custom_field_value.name }}</label>
                          {% endif %}
                        </div>
                      {% endfor %}
                    </div>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'checkbox' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <div>
                      {% for custom_field_value in custom_field.custom_field_value %}
                        <div class="form-check">
                          {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id in register_custom_field[custom_field.custom_field_id] %}
                            <label><input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input" checked="checked"/>
                              {{ custom_field_value.name }}</label>
                          {% else %}
                            <label><input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/>
                              {{ custom_field_value.name }}</label>
                          {% endif %}
                        </div>
                      {% endfor %}
                    </div>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'text' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'textarea' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <textarea name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}</textarea>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'file' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <button type="button" id="button-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="btn btn-light"><i class="fas fa-upload"></i> {{ button_upload }}</button>
                    <input type="hidden" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}  {{ register_custom_field[custom_field.custom_field_id] }} {% endif %}"/>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'date' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <div class="input-group date">
                      <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                      <div class="input-group-append">
                        <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                      </div>
                    </div>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'time' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <div class="input-group time">
                      <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                      <div class="input-group-append">
                        <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                      </div>
                    </div>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
              {% if custom_field.type == 'datetime' %}
                <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group row custom-field" data-sort="{{ custom_field.sort_order }}">
                  <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                  <div class="col-sm-10">
                    <div class="input-group datetime">
                      <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                      <div class="input-group-append">
                        <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                      </div>
                    </div>
                    {% if error_custom_field[custom_field.custom_field_id] %}
                      <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                    {% endif %}
                  </div>
                </div>
              {% endif %}
            {% endif %}
          {% endfor %}
        </fieldset>
        <fieldset id="affiliate">
          <legend>{{ text_your_affiliate }}</legend>
          <div class="form-group row">
            <label class="col-sm-2 col-form-label" for="input-company">{{ entry_company }}</label>
            <div class="col-sm-10">
              <input type="text" name="company" value="{{ company }}" placeholder="{{ entry_company }}" id="input-company" class="form-control"/>
            </div>
          </div>

          <div class="form-group row">
            <label class="col-sm-2 col-form-label" for="input-website">{{ entry_website }}</label>
            <div class="col-sm-10">
              <input type="text" name="website" value="{{ website }}" placeholder="{{ entry_website }}" id="input-website" class="form-control"/>
            </div>
          </div>
          <div class="form-group row">
            <label class="col-sm-2 col-form-label" for="input-tax">{{ entry_tax }}</label>
            <div class="col-sm-10">
              <input type="text" name="tax" value="{{ tax }}" placeholder="{{ entry_tax }}" id="input-tax" class="form-control"/>
            </div>
          </div>
          <div class="form-group row">
            <label class="col-sm-2 col-form-label">{{ entry_payment }}</label>
            <div class="col-sm-10">
              <div class="form-check">
                <label>
                  {% if payment == 'cheque' %}
                    <input type="radio" name="payment" value="cheque" class="form-check-input" checked="checked"/>
                  {% else %}
                    <input type="radio" name="payment" value="cheque" class="form-check-input"/>
                  {% endif %}
                  {{ text_cheque }}
                </label>
              </div>
              <div class="form-check">
                <label>
                  {% if payment == 'paypal' %}
                    <input type="radio" name="payment" value="paypal" class="form-check-input" checked="checked"/>
                  {% else %}
                    <input type="radio" name="payment" value="paypal" class="form-check-input"/>
                  {% endif %}
                  {{ text_paypal }}
                </label>
              </div>
              <div class="form-check">
                <label>
                  {% if payment == 'bank' %}
                    <input type="radio" name="payment" value="bank" class="form-check-input" checked="checked"/>
                  {% else %}
                    <input type="radio" name="payment" value="bank" class="form-check-input"/>
                  {% endif %}
                  {{ text_bank }}
                </label>
              </div>
            </div>
          </div>
          <div class="form-group row payment required" id="payment-cheque">
            <label class="col-sm-2 col-form-label" for="input-cheque">{{ entry_cheque }}</label>
            <div class="col-sm-10">
              <input type="text" name="cheque" value="{{ cheque }}" placeholder="{{ entry_cheque }}" id="input-cheque" class="form-control"/>
              {% if error_cheque %}
                <div class="text-danger">{{ error_cheque }}</div>
              {% endif %}
            </div>
          </div>
          <div class="form-group row payment required" id="payment-paypal">
            <label class="col-sm-2 col-form-label" for="input-paypal">{{ entry_paypal }}</label>
            <div class="col-sm-10">
              <input type="text" name="paypal" value="{{ paypal }}" placeholder="{{ entry_paypal }}" id="input-paypal" class="form-control"/>
              {% if error_paypal %}
                <div class="text-danger">{{ error_paypal }}</div>
              {% endif %}
            </div>
          </div>
          <div class="payment" id="payment-bank">
            <div class="form-group row">
              <label class="col-sm-2 col-form-label" for="input-bank-name">{{ entry_bank_name }}</label>
              <div class="col-sm-10">
                <input type="text" name="bank_name" value="{{ bank_name }}" placeholder="{{ entry_bank_name }}" id="input-bank-name" class="form-control"/>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-sm-2 col-form-label" for="input-bank-branch-number">{{ entry_bank_branch_number }}</label>
              <div class="col-sm-10">
                <input type="text" name="bank_branch_number" value="{{ bank_branch_number }}" placeholder="{{ entry_bank_branch_number }}" id="input-bank-branch-number" class="form-control"/>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-sm-2 col-form-label" for="input-bank-swift-code">{{ entry_bank_swift_code }}</label>
              <div class="col-sm-10">
                <input type="text" name="bank_swift_code" value="{{ bank_swift_code }}" placeholder="{{ entry_bank_swift_code }}" id="input-bank-swift-code" class="form-control"/>
              </div>
            </div>
            <div class="form-group row required">
              <label class="col-sm-2 col-form-label" for="input-bank-account-name">{{ entry_bank_account_name }}</label>
              <div class="col-sm-10">
                <input type="text" name="bank_account_name" value="{{ bank_account_name }}" placeholder="{{ entry_bank_account_name }}" id="input-bank-account-name" class="form-control"/>
                {% if error_bank_account_name %}
                  <div class="text-danger">{{ error_bank_account_name }}</div>
                {% endif %}
              </div>
            </div>
            <div class="form-group row required">
              <label class="col-sm-2 col-form-label" for="input-bank-account-number">{{ entry_bank_account_number }}</label>
              <div class="col-sm-10">
                <input type="text" name="bank_account_number" value="{{ bank_account_number }}" placeholder="{{ entry_bank_account_number }}" id="input-bank-account-number" class="form-control"/>
                {% if error_bank_account_number %}
                  <div class="text-danger">{{ error_bank_account_number }}</div>
                {% endif %}
              </div>
            </div>
            {% for custom_field in custom_fields %}
              {% if custom_field.location == 'affiliate' %}
                {% if custom_field.type == 'select' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <select name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">
                        <option value="">{{ text_select }}</option>
                        {% for custom_field_value in custom_field.custom_field_value %}
                          {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
                            <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option>
                          {% else %}
                            <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
                          {% endif %}
                        {% endfor %}
                      </select>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'radio' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <div>
                        {% for custom_field_value in custom_field.custom_field_value %}
                          <div class="form-check"> {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
                              <label><input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input" checked="checked"/>
                                {{ custom_field_value.name }}</label>
                            {% else %}
                              <label><input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/>
                                {{ custom_field_value.name }}</label>
                            {% endif %}
                          </div>
                        {% endfor %}
                      </div>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'checkbox' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <div>
                        {% for custom_field_value in custom_field.custom_field_value %}
                          <div class="form-check">
                            {% if register_custom_field[custom_field.custom_field_id] and custom_field_value.custom_field_value_id == register_custom_field[custom_field.custom_field_id] %}
                              <label><input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input" checked="checked"/>
                                {{ custom_field_value.name }}</label>
                            {% else %}
                              <label><input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/>
                                {{ custom_field_value.name }}</label>
                            {% endif %}
                          </div>
                        {% endfor %}
                      </div>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'text' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'textarea' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <textarea name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}</textarea>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'file' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <button type="button" id="button-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="btn btn-light"><i class="fas fa-upload"></i> {{ button_upload }}</button>
                      <input type="hidden" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}  {{ register_custom_field[custom_field.custom_field_id] }} {% endif %}"/>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'date' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <div class="input-group date">
                        <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                        <div class="input-group-append">
                          <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                        </div>
                      </div>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'time' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <div class="input-group time">
                        <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                        <div class="input-group-append">
                          <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                        </div>
                      </div>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
                {% if custom_field.type == 'datetime' %}
                  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field" data-sort="{{ custom_field.sort_order }}">
                    <label class="col-sm-2 col-form-label" for="input-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
                    <div class="col-sm-10">
                      <div class="input-group datetime">
                        <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{% if register_custom_field[custom_field.custom_field_id] %}{{ register_custom_field[custom_field.custom_field_id] }}{% else %}{{ custom_field.value }}{% endif %}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control"/>
                        <div class="input-group-append">
                          <span class="input-group-text"><i class="fas fa-calendar"></i></span>
                        </div>
                      </div>
                      {% if error_custom_field[custom_field.custom_field_id] %}
                        <div class="text-danger">{{ error_custom_field[custom_field.custom_field_id] }}</div>
                      {% endif %}
                    </div>
                  </div>
                {% endif %}
              {% endif %}
            {% endfor %}
          </div>
        </fieldset>
        <fieldset>
          <legend>{{ text_your_password }}</legend>
          <div class="form-group row required">
            <label class="col-sm-2 col-form-label" for="input-password">{{ entry_password }}</label>
            <div class="col-sm-10">
              <input type="password" name="password" value="{{ password }}" placeholder="{{ entry_password }}" id="input-password" class="form-control"/>
              {% if error_password %}
                <div class="text-danger">{{ error_password }}</div>
              {% endif %}
            </div>
          </div>
          <div class="form-group row required">
            <label class="col-sm-2 col-form-label" for="input-confirm">{{ entry_confirm }}</label>
            <div class="col-sm-10">
              <input type="password" name="confirm" value="{{ confirm }}" placeholder="{{ entry_confirm }}" id="input-confirm" class="form-control"/>
              {% if error_confirm %}
                <div class="text-danger">{{ error_confirm }}</div>
              {% endif %}
            </div>
          </div>
        </fieldset>
        {{ captcha }}
        {% if text_agree %}
          <div class="d-inline-block pt-2 pd-2 w-100">
            <div class="float-right">{{ text_agree }}
              {% if agree %}
                <input type="checkbox" name="agree" value="1" checked="checked"/>
              {% else %}
                <input type="checkbox" name="agree" value="1"/>
              {% endif %}
              &nbsp;
              <button type="submit" class="btn btn-primary">{{ button_continue }}</button>
            </div>
          </div>
        {% else %}
          <div class="d-inline-block pt-2 pd-2 w-100">
            <div class="float-right">
              <button type="submit" class="btn btn-primary">{{ button_continue }}</button>
            </div>
          </div>
        {% endif %}
      </form>
      {{ content_bottom }}
    </div>
    {{ column_right }}
  </div>
</div>
<script type="text/javascript"><!--
// Sort the custom fields
$('#account .form-group[data-sort]').detach().each(function() {
	if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#account .form-group').length) {
		$('#account .form-group').eq($(this).attr('data-sort')).before(this);
	}

	if ($(this).attr('data-sort') > $('#account .form-group').length) {
		$('#account .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') == $('#account .form-group').length) {
		$('#account .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') < -$('#account .form-group').length) {
		$('#account .form-group:first').before(this);
	}
});

$('#affiliate .form-group[data-sort]').detach().each(function() {
	if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#affiliate .form-group').length) {
		$('#affiliate .form-group').eq($(this).attr('data-sort')).before(this);
	}

	if ($(this).attr('data-sort') > $('#affiliate .form-group').length) {
		$('#affiliate .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') == $('#affiliate .form-group').length) {
		$('#affiliate .form-group:last').after(this);
	}

	if ($(this).attr('data-sort') < -$('#affiliate .form-group').length) {
		$('#affiliate .form-group:first').before(this);
	}
});

$('input[name=\'customer_group_id\']').on('change', function() {
	$.ajax({
		url: 'index.php?route=account/register/customfield&customer_group_id=' + this.value,
		dataType: 'json',
		success: function(json) {
			$('.custom-field').hide();
			$('.custom-field').removeClass('required');

			for (i = 0; i < json.length; i++) {
				custom_field = json[i];

				$('#custom-field' + custom_field['custom_field_id']).show();

				if (custom_field['required']) {
					$('#custom-field' + custom_field['custom_field_id']).addClass('required');
				}
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});

$('input[name=\'customer_group_id\']:checked').trigger('change');
//--></script>
<script type="text/javascript"><!--
$('button[id^=\'button-custom-field\']').on('click', function() {
	var element = this;

	$('#form-upload').remove();

	$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

	$('#form-upload input[name=\'file\']').trigger('click');

	if (typeof timer != 'undefined') {
		clearInterval(timer);
	}

	timer = setInterval(function() {
		if ($('#form-upload input[name=\'file\']').val() != '') {
			clearInterval(timer);

			$.ajax({
				url: 'index.php?route=tool/upload',
				type: 'post',
				dataType: 'json',
				data: new FormData($('#form-upload')[0]),
				cache: false,
				contentType: false,
				processData: false,
				beforeSend: function() {
					$(element).button('loading');
				},
				complete: function() {
					$(element).button('reset');
				},
				success: function(json) {
					$(element).parent().find('.text-danger').remove();

					if (json['error']) {
						$(element).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
					}

					if (json['success']) {
						alert(json['success']);

						$(element).parent().find('input').val(json['code']);
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
		}
	}, 500);
});
//--></script>
<script type="text/javascript"><!--
$('.date').datetimepicker({
	'format': 'YYYY-MM-DD',
	'locale': '{{ datepicker }}',
	'allowInputToggle': true
});

$('.time').datetimepicker({
	'format': 'HH:mm',
	'locale': '{{ datepicker }}',
	'allowInputToggle': true
});

$('.datetime').datetimepicker({
	'format': 'YYYY-MM-DD HH:mm',
	'locale': '{{ datepicker }}',
	'allowInputToggle': true
});
//--></script>
<script type="text/javascript"><!--
$('input[name=\'payment\']').on('change', function() {
	$('.payment').hide();

	$('#payment-' + this.value).show();
});

$('input[name=\'payment\']:checked').trigger('change');
//--></script>
{{ footer }}
